﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Comm;

public partial class Web_Admin_SiteInfo_systemkeyword_list : AdminPageBase
{
    private BSystemKeyword bll = new BSystemKeyword();
    protected void Page_Load(object sender, EventArgs e)
    {
        base.CheckPopedomInfoRedirect(1007, 1);
        but_window.Enabled = but_diswindow.Enabled = base.CheckPopedomInfo(1007, 128);
        but_enable.Enabled = but_disenable.Enabled = base.CheckPopedomInfo(1007, 64);
        but_delete.Enabled = base.CheckPopedomInfo(1007, 8);
        if (!IsPostBack)
        {
            loadData();
        }
    }

    /// <summary>
    /// 加载数据
    /// </summary>
    private void loadData()
    {
        List<MSystemKeyword> list = bll.getList("");
        rpList.DataSource = list;
        rpList.DataBind();
        lit_nodata.Visible = list == null || list.Count < 1 ? true : false;
    }

    /// <summary>
    /// 删除
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void but_delete_Click(object sender, EventArgs e)
    {
        string ids = Request.Form["checkboxs"];
        if (ids == null || ids.Trim() == "")
        {
            return;
        }

        foreach (string id in ids.Split(','))
        {
            bll.Delete(id);
        }
        base.AddLog(3, "系统关键词管理ID：" + ids);
        loadData();
    }

    /// <summary>
    /// 启用
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void but_enable_Click(object sender, EventArgs e)
    {
        string ids = Request.Form["checkboxs"];
        if (ids == null || ids.Trim() == "")
        {
            return;
        }

        foreach (string id in ids.Split(','))
        {
            bll.UpdateEnabled(true, id);
        }
        base.AddLog(2, "启用系统关键词管理ID：" + ids);
        loadData();
    }

    /// <summary>
    /// 关闭
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void but_disenable_Click(object sender, EventArgs e)
    {
        string ids = Request.Form["checkboxs"];
        if (ids == null || ids.Trim() == "")
        {
            return;
        }

        foreach (string id in ids.Split(','))
        {
            bll.UpdateEnabled(false, id);
        }
        base.AddLog(2, "关闭系统关键词管理ID：" + ids);
        loadData();
    }

    /// <summary>
    /// 新窗口打开
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void but_window_Click(object sender, EventArgs e)
    {
        string ids = Request.Form["checkboxs"];
        if (ids == null || ids.Trim() == "")
        {
            return;
        }

        foreach (string id in ids.Split(','))
        {
            bll.UpdateNewWindow(true, id);
        }
        base.AddLog(2, "通过打开新窗口系统关键词管理ID：" + ids);
        loadData();
    }

    /// <summary>
    /// 取消新窗口打开
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void but_diswindow_Click(object sender, EventArgs e)
    {
        string ids = Request.Form["checkboxs"];
        if (ids == null || ids.Trim() == "")
        {
            return;
        }

        foreach (string id in ids.Split(','))
        {
            bll.UpdateNewWindow(false, id);
        }
        base.AddLog(2, "取消打开新窗口系统关键词管理ID：" + ids);
        loadData();
    }
}
